package com.shigen.demo.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shigen.demo.annotation.RequestLimit;
import com.shigen.demo.bean.Result;
import com.shigen.demo.entity.UpdateLog;
import com.shigen.demo.entity.req.UpdateLogReq;
import com.shigen.demo.service.IUpdateLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.annotation.Resource;
import javax.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "updatelog")
@Api(tags = "更新日志")
public class UpdateLogController {

  @Resource
  private IUpdateLogService updateLogService;

  @PostMapping(value = "select")
  @ApiOperation(value = "根据作者名字或更新内容分页查询更新日志")
  @RequestLimit(second = 2)
  public Object selectAllUpdateLogs(@RequestBody @Valid UpdateLogReq.QueryItem queryItem) {
    IPage<UpdateLog> updateLogs = updateLogService.getUpdateLogs(queryItem);
    return Result.ok(updateLogs);
  }
}
